%CHOOSNW  calls up a window for estimation of optimal bandwidth for
%         Nadaraya - Watson estimator
%
%     Use only in procedure KERN
%
% (C) Jan Kolacek, Masaryk University (Czech Republic)

if ~exist('Inmat','var')
   Inmat=zeros(12,4);Inp=Inmat;
else
   Inmat(:,1)=0;Inp=Inmat;
end;
bcgcol=[.8529 .8529 .8529];
tw=0.08;
editFig=findobj(0,'name','EDIT');
hndlList=get(editFig,'UserData');   
hHndl=hndlList(4);
nwstr='Choosing the optimal bandwidth for the Nadaraya - Watson estimator';
callstr=['sez=findobj(gcf,''style'',''radiobutton'');set(sez,''Value'',0);set(gco,''Value'',1);',...
    'tg=get(gco,''Tag'');vedle=findobj(gcf,''Tag'',tg(1:end-3));actual=get(vedle,''string'');hpom=actual(2,5:end);',...
    'set(acth,''String'',hpom);set(hHndl,''String'',hpom);h=str2num(hpom);save v.mat h -append;'];

uicontrol( ...
     	  'Style','text', ...
        'Units','normalized', ...
        'Position',[0.15,hor-.15,.7,.13], ...
        'ForegroundColor','blue', ...
        'BackgroundColor',[.7 .7 .7], ...
        'FontSize',13,...
        'FontUnits','normalized',...
        'String',nwstr);
     
 uicontrol( ...
        'Style','frame', ...
        'Units','normalized', ...
        'Position',[vert-.01,hor-16*vys-.03,.55,.67], ...
        'BackgroundColor',bcgcol);
     
 uicontrol( ...
     	  'Style','text', ...
        'Units','normalized', ...
        'Position',[vert,hor-4*vys-.02,.53,.05], ...
        'FontSize',12,...
        'FontUnits','normalized',...
        'BackgroundColor',bcgcol,...
        'String','Penalizing functions');
%        'ForegroundColor',[0.6 .9 0.9], ...
     
%generalized cross-validation    
 uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert+.27,hor-12*vys-.05,.13,.05], ...
         'BackgroundColor',[.5,0.5,0.5], ...
         'Callback',['set(nwgcv,''String'',''wait ...'');pause(.1);',...
         '[h,g,hhg1,gcv1,gtr1]=gcvnw(x,y,n,k,m);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwgcv,''String'',CH);Inmat(1,1)=1;Inp(1,1)=1;',...
         'set(nwgcvz,''Enable'',''on'');set(nwgcvset,''Visible'',''on'');'],...   
         'String','Generaliz. CV');
         
nwgcv=uicontrol( ...
	'Style','text', ...
   'Units','normalized', ...
   'FontUnits','normalized',...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.135+.27,hor-13*vys-.05,tw,.08], ...
   'HorizontalAlignment','left',...
   'Tag','nwgcv',...
   'String','');
            
nwgcvz=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert+.27,hor-13*vys-.05,.13,.05], ...
          'Callback',['figure;plot(hhg1,gcv1,''r'');',...
          'title(''GCV dependence on h for NW estimator'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','draw',...
          'Enable','off');       

nwgcvset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.215+.27,hor-13*vys-.05,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwgcvset',...
   'String','');
       
%Classic cross-validation       
uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert,hor-6*vys-.02,.13,.05], ...
         'Callback',['set(nwcv,''String'',''wait ...'');pause(.1);',...
         '[h,g,hhcv1,cv1]=cvnw(x,y,n,k,m);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwcv,''String'',CH);Inmat(11,1)=1;Inp(11,1)=1;',...
         'set(nwcvz,''Enable'',''on'');set(nwcvset,''Visible'',''on'');'],...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'ForegroundColor',[.6,0.2,0.2], ...
         'String','Classic CV');
         
nwcv=uicontrol( ...
	'Style','text', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.135,hor-7*vys-.02,tw,.08], ...
   'HorizontalAlignment','left',...
   'Tag','nwcv',...
   'String','');
            
nwcvz=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert,hor-7*vys-.02,.13,.05], ...
          'Callback',['figure;plot(hhcv1,cv1,''r'');',...
          'title(''Classic CV dependence on h for NW estimator'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'ForegroundColor',[.6,0.2,0.2], ...
          'String','draw',...
          'Enable','off');       
       
nwcvset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.215,hor-7*vys-.02,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwcvset',...
   'String','');

%Akaike       
uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert+.27,hor-8*vys-.03,.13,.05], ...
         'Callback',['set(nwacv,''String'',''wait ...'');pause(.1);',...
         '[h,g,hha1,acv1,atr1]=acvnw(x,y,n,k,m);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwacv,''String'',CH);Inmat(2,1)=1;Inp(2,1)=1;',...
         'set(nwacvz,''Enable'',''on'');set(nwacvset,''Visible'',''on'');'],...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'String','Akaike CV');
         
nwacv=uicontrol( ...
	'Style','text', ...
   'BackgroundColor',bcgcol,...
   'Units','normalized', ...
   'FontUnits','normalized',...
   'Position',[vert+.135+.27,hor-9*vys-.03,tw,.08], ...
   'HorizontalAlignment','left',...
   'Tag','nwacv',...
   'String','');
            
nwacvz=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert+.27,hor-9*vys-.03,.13,.05], ...
          'Callback',['figure;plot(hha1,acv1,''r'');',...
          'title(''Akaike CV dependence on h for NW estimator'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','draw',...
          'Enable','off');       

nwacvset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.215+.27,hor-9*vys-.03,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwacvset',...
   'String','');
      
%Finite prediciton       
uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert+.27,hor-6*vys-.02,.13,.05], ...
         'Callback',['set(nwfpecv,''String'',''wait ...'');pause(.1);',...
         '[h,g,hhfp1,fpcv1,fptr1]=fpecvnw(x,y,n,k,m);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwfpecv,''String'',CH);Inmat(3,1)=1;Inp(3,1)=1;',...
         'set(nwfpecvz,''Enable'',''on'');set(nwfpecvset,''Visible'',''on'');'],...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'String','Fin. pred. CV');
         
nwfpecv=uicontrol( ...
	'Style','text', ...
   'Units','normalized', ...
   'FontUnits','normalized',...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.135+.27,hor-7*vys-.02,tw,.08], ...
   'HorizontalAlignment','left',...
   'Tag','nwfpecv',...
   'String','');
            
nwfpecvz=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert+.27,hor-7*vys-.02,.13,.05], ...
          'Callback',['figure;plot(hhfp1,fpcv1,''r'');',...
          'title(''FPECV dependence on h for NW estimator'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','draw',...
          'Enable','off');       

nwfpecvset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.215+.27,hor-7*vys-.02,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwfpecvset',...
   'String','');
      
%Shibata
uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert,hor-8*vys-.03,.13,.05], ...
         'Callback',['set(nwscv,''String'',''wait ...'');pause(.1);',...
         '[h,g,hhs1,scv1,str1]=scvnw(x,y,n,k,m);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwscv,''String'',CH);Inmat(4,1)=1;Inp(4,1)=1;',...
         'set(nwscvz,''Enable'',''on'');set(nwscvset,''Visible'',''on'');'],...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'String','Shibata CV');
         
nwscv=uicontrol( ...
	'Style','text', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.135,hor-9*vys-.03,tw,.08], ...
   'HorizontalAlignment','left',...
   'Tag','nwscv',...
   'String','');
            
nwscvz=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert,hor-9*vys-.03,.13,.05], ...
          'Callback',['figure;plot(hhs1,scv1,''r'');',...
          'title(''SCV dependence on h for NW estimator'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','draw',...
          'Enable','off');       
      
nwscvset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.215,hor-9*vys-.03,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwscvset',...
   'String','');

%Rice     
uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert,hor-10*vys-.04,.13,.05], ...
         'Callback',['set(nwrcv,''String'',''wait ...'');pause(.1);',...
         '[h,g,hhr1,rcv1,rtr1]=rcvnw(x,y,n,k,m);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwrcv,''String'',CH);Inmat(5,1)=1;Inp(5,1)=1;',...
         'set(nwrcvz,''Enable'',''on'');set(nwrcvset,''Visible'',''on'');'],...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'String','Rice CV');
         
nwrcv=uicontrol( ...
	'Style','text', ...
   'Units','normalized', ...
   'FontUnits','normalized',...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.135,hor-11*vys-.04,tw,.08], ...
   'HorizontalAlignment','left',...
   'Tag','nwrcv',...
   'String','');
            
nwrcvz=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert,hor-11*vys-.04,.13,.05], ...
          'Callback',['figure;plot(hhr1,rcv1,''r'');',...
          'title(''RCV dependence on h for NW estimator'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','draw',...
          'Enable','off');       

nwrcvset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.215,hor-11*vys-.04,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwrcvset',...
   'String','');
      
%Full       
uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert,hor-12*vys-.05,.13,.05], ...
         'Callback',['set(nwfcv,''String'',''wait ...'');pause(.1);',...
         '[h,g,hhf1,fcv1,ftr1]=fcvnw(x,y,n,k,m);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwfcv,''String'',CH);Inmat(6,1)=1;Inp(6,1)=1;',...
         'set(nwfcvz,''Enable'',''on'');set(nwfcvset,''Visible'',''on'');'],...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'String','Full CV');
         
nwfcv=uicontrol( ...
	'Style','text', ...
   'Units','normalized', ...
   'FontUnits','normalized',...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.135,hor-13*vys-.05,tw,.08], ...
   'HorizontalAlignment','left',...
   'Tag','nwfcv',...
   'String','');
            
nwfcvz=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert,hor-13*vys-.05,.13,.05], ...
          'Callback',['figure;plot(hhf1,fcv1,''r'');',...
          'title(''FCV dependence on h for NW estimator'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','draw',...
          'Enable','off');       
      
nwfcvset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.215,hor-13*vys-.05,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwfcvset',...
   'String','');

%Moje       
uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert+.27,hor-10*vys-.04,.13,.05], ...
         'Callback',['set(nwkcv,''String'',''wait ...'');pause(.1);',...
         '[h,g,hhk1,kcv1,ktr1]=knw(x,y,n,k,m);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwkcv,''String'',CH);Inmat(7,1)=1;Inp(7,1)=1;',...
         'set(nwkcvz,''Enable'',''on'');set(nwkcvset,''Visible'',''on'');'],...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'String','Kolacek CV');
         
nwkcv=uicontrol( ...
	'Style','text', ...
   'Units','normalized', ...
   'FontUnits','normalized',...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.135+.27,hor-11*vys-.04,tw,.08], ...
   'HorizontalAlignment','left',...
   'Tag','nwkcv',...
   'String','');
            
nwkcvz=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert+.27,hor-11*vys-.04,.13,.05], ...
          'Callback',['figure;plot(hhk1,kcv1,''r'');',...
          'title(''KCV dependence on h for NW estimator'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','draw',...
          'Enable','off');    
      
nwkcvset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.215+.27,hor-11*vys-.04,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwkcvset',...
   'String','');
      
% Ostatni       
uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert+.26,hor-18*vys-.04,.28,.07], ...
         'Callback','Inmat=Inp;drallnw;',...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'String','Draw all error functions');

uicontrol('Style','text','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert+.55,hor-18*vys-.06,.08,.07], ...
         'BackgroundColor',[.7 .7 .7],...
         'String','Actual h:');
     
acth=uicontrol('Style','text','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert+.63,hor-18*vys-.06,.08,.07], ...
         'HorizontalAlignment','left',...
         'BackgroundColor',[.7 .7 .7],...
         'String','none');

uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert+.1,hor-16*vys,.3,.07], ...
         'Callback','Inmat=Inp;drallpennw;',...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'String','Draw all penalizing functions');
      
%Odhsig frame
uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert,hor-17*vys-.04,.13,.05], ...
         'Callback',['set(nwsig,''String'',''wait ...'');pause(.1);',...
         '[h,g,hhsig1,sigcv1]=signw(x,y,n,k,m);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwsig,''String'',CH);Inmat(9,1)=1;Inp(9,1)=1;',...
         'set(nwsigz,''Enable'',''on'');set(nwsigset,''Visible'',''on'');'],...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'String','Mallows');
         
nwsig=uicontrol( ...
	'Style','text', ...
   'Units','normalized', ...
   'FontUnits','normalized',...
   'Position',[vert+.135,hor-18*vys-.04,tw,.08], ...
   'HorizontalAlignment','left',...
   'BackgroundColor',[.7 .7 .7],...
   'Tag','nwsig',...
   'String','');
            
nwsigz=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert,hor-18*vys-.04,.13,.05], ...
          'Callback',['figure;plot(hhsig1,sigcv1,''r'');',...
          'title(''Mallows dependence on h for NW estimator'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','draw',...
          'Enable','off');       

nwsigset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',[.7 .7 .7],...
   'Position',[vert+.215,hor-18*vys-.04,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwsigset',...
   'String','');
      
%Chiu frame      
uicontrol( ...
        'Style','frame', ...
        'Units','normalized', ...
        'Position',[vert+.55,hor-10*vys+.01+.09,.39,.24], ...
        'BackgroundColor',bcgcol);
     
uicontrol( ...
     	  'Style','text', ...
        'Units','normalized', ...
        'BackgroundColor',bcgcol,...
        'Position',[vert+.56,hor-4*vys-.005,.37,.04], ...
        'FontSize',12,...
        'FontUnits','normalized',...
        'String','Fourier');
     
 % First, the MiniCommand Window frame
    
    uicontrol( ...
        'Style','frame', ...
        'Units','normalized', ...
        'Position',[vert+.6,hor-6*vys-.02+0.05,.3,.06], ...
	     'BackgroundColor',[0.50 0.50 0.50]);
%pause;
% Then the text label
    
uicontrol( ...
	     'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'Position',[vert+.615,hor-6*vys-.015+0.05,.14,.04], ...
        'BackgroundColor',[0.50 0.50 0.50], ...
	     'ForegroundColor',[1 1 1], ...
        'String','Set constant c');
    
cHndl=uicontrol('Style','edit', ...
        'Units','normalized', ...
        'Max',1, ...
        'Min',1, ...
        'BackgroundColor',[1 1 1], ...
        'FontUnits','normalized',...
        'Position',[vert+.76,hor-6*vys+0.04,.12,.045], ...
        'String','2',...%%%%
        'HorizontalAlignment','left'); 
    
 chih=uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert+.62,hor-8*vys+0.065,.13,.05], ...
         'Callback',['set(nwchcv,''String'',''wait ...'');pause(.1);',...
         'c=str2num(get(cHndl,''string''));[h,g,hhch1,chcv1]=chnw(x,y,n,k,m,c);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwchcv,''String'',CH);Inmat(8,1)=1;Inp(8,1)=1;',...
         'set(nwchcvz,''Enable'',''on'');set(nwchcvset,''Visible'',''on'');'],...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'String','Fourier');
         
nwchcv=uicontrol( ...
	'Style','text', ...
   'Units','normalized', ...
   'FontUnits','normalized',...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.76,hor-9*vys+.065,.14,.08], ...
   'HorizontalAlignment','left',...
   'Tag','nwchcv',...
   'String','');
            
nwchcvz=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert+.62,hor-9*vys+.065,.13,.05], ...
          'Callback',['figure;plot(hhch1,chcv1,''r'');',...
          'title(''Fourier dependence on h for NW estimator'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','draw',...
          'Enable','off');     
      
nwchcvset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.84,hor-9*vys+.065,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwchcvset',...
   'String','');
      
%Plug-in frame     
uicontrol( ...
        'Style','frame', ...
        'Units','normalized', ...
        'Position',[vert+.55,hor-16*vys-.03+.23,.39,.19], ...
        'BackgroundColor',bcgcol);
     
uicontrol( ...
     	  'Style','text', ...
        'Units','normalized', ...
        'BackgroundColor',bcgcol,...
        'Position',[vert+.56,hor-10*vys-.06-.11+.2,.37,.05], ...
        'FontSize',12,...
        'FontUnits','normalized',...
        'String','Plug-in');
pluginh=uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert+.62,hor-16*vys+.05+0.22,.13,.05], ...
         'Callback',['set(nwplugin,''String'',''wait ...'');pause(.1);',...
         '[h,g,hhplugin,fplugin]=plugin(x,y,n,k,m,1);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwplugin,''String'',CH);Inmat(12,1:4)=1;Inp(12,1:4)=1;',...
         'set(nwpluginz,''Enable'',''on'');set(nwpluginset,''Visible'',''on'');'],...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'String','Plug-in');
nwplugin=uicontrol( ...
	'Style','text', ...
   'Units','normalized', ...
   'FontUnits','normalized',...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.76,hor-16*vys+.22,.13,.08], ...
   'HorizontalAlignment','left',...
   'Tag','nwplugin',...
   'String','');
            
nwpluginz=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert+.62,hor-16*vys+0.22,.13,.05], ...
          'Callback',['figure;plot(hhplugin,fplugin,''r'');',...
          'title(''Plug-in dependence on h'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','draw',...
          'Enable','off');       
      
nwpluginset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.84,hor-16*vys+.22,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwpluginset',...
   'String','');
      
%MSE frame     
uicontrol( ...
        'Style','frame', ...
        'Units','normalized', ...
        'Position',[vert+.55,hor-16*vys-.03,.39,.22], ...
        'BackgroundColor',bcgcol);
     
uicontrol( ...
     	  'Style','text', ...
        'Units','normalized', ...
        'BackgroundColor',bcgcol,...
        'Position',[vert+.56,hor-10*vys-.06-.11,.37,.04], ...
        'FontSize',12,...
        'FontUnits','normalized',...
        'String','MSE');
     
msewar=uicontrol( ...
     	  'Style','text', ...
        'Units','normalized', ...
        'FontUnits','normalized',...
        'BackgroundColor',bcgcol,...
        'Position',[vert+.56,hor-11*vys-.06-.1,.37,.04], ...
        'String','(Only for known regression function)');
     
mseh=uicontrol('Style','push','Units','normalized', ...
         'FontUnits','normalized',...
         'Position',[vert+.62,hor-16*vys+.035,.13,.05], ...
         'Callback',['set(nwmse,''String'',''wait ...'');pause(.1);',...
         '[h,g,hhmse,fmse]=mse(x,y,f,''t'',n,k,m);',...
         'CH=char([''= '',num2str(g,3)],[''h = '',num2str(h,4)]);',...
         'set(nwmse,''String'',CH);Inmat(10,1:4)=1;Inp(10,1:4)=1;',...
         'set(nwmsez,''Enable'',''on'');set(nwmseset,''Visible'',''on'');'],...   
         'BackgroundColor',[.5,0.5,0.5], ...
         'Enable','off',...
         'String','MSE');
            
if ff      
switch ~~exist('sym')
case {0}
   set(msewar,'String','No symbolic toolbox!','ForegroundColor','red');
case {1}
   set(mseh,'Enable','on');
end;
else
   set(msewar,'String','Unknown regression function!','ForegroundColor','red');
end;
      
nwmse=uicontrol( ...
	'Style','text', ...
   'Units','normalized', ...
   'FontUnits','normalized',...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.76,hor-16*vys-.015,.13,.08], ...
   'HorizontalAlignment','left',...
   'Tag','nwmse',...
   'String','');
            
nwmsez=uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[vert+.62,hor-16*vys-.015,.13,.05], ...
          'Callback',['figure;plot(hhmse,fmse,''r'');',...
          'title(''MSE dependence on h'');'],...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','draw',...
          'Enable','off');
      
nwmseset=uicontrol( ...
	'Style','radiobutton', ...
   'FontUnits','normalized',...
   'Units','normalized', ...
   'BackgroundColor',bcgcol,...
   'Position',[vert+.84,hor-16*vys-.015,.04,.1], ...
   'Callback',callstr,...
   'Visible','off',...
   'Tag','nwmseset',...
   'String','');
     
uicontrol('Style','push','Units','normalized', ...
          'FontUnits','normalized',...
          'Position',[.84,.05,.14,.08], ...
          'Callback','close;', ...
          'BackgroundColor',[.5,0.5,0.5], ...
          'String','Close');
      
%set(gcf,'Units','Normalized','Position',[0 0.0347 1.0000 0.9190]);
set(gcf,'Units','Normalized','Position',[0.1059 0.1655 0.7700 0.6898]);
       
